// 全局过滤器
import searchOptions from "./options";

const createFilter = (Vue, name) => {
  Vue.filter(`${name}Filter`, value => {
    let ret = "";
    if (value || value === 0) {
      for (const item of searchOptions[name]) {
        if (item.value === value) {
          ret = item.label;
          break;
        }
      }
    }
    return ret;
  });
};

export default Vue => {
  // Vue.filter('sexFilter', value => {
  //   if (value === undefined) return ''
  //   if (value === 0) return '男'
  //   if (value === 1) return '女'
  // })
  /* 开关状态 */
  createFilter(Vue, "status");

  /* 订单状态 */
  createFilter(Vue, "orderStatus");

  /* 付款方式 */
  createFilter(Vue, "payType");

  /* 患者类型 */
  createFilter(Vue, "patientType");

  /* 性别 */
  createFilter(Vue, "sex");
};
